home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Archiv / Install_3.3.lha / Install_3.3 / ARexx / Install_Request.dopus5 < prev    next >
Text File  |  1997-05-09  |  7KB  |  255 lines

  1. /* $VER: Install_Request.dopus5 3.1 (09.05.97) © Frédéric Steinfels
  2. */
  3.  
  4. signal on BREAK_C
  5. signal on BREAK_D
  6. signal on BREAK_E
  7. signal on BREAK_F
  8. signal on HALT
  9. signal on IOERR
  10. signal on SYNTAX
  11. signal on FAILURE
  12. options failat 21
  13. options results
  14. parse arg arguments
  15. ProgramName = "Install_Request.dopus5";
  16. ArgsTemplate = "PORT/A,MNPORT/A,EXPORT/A,MYPORT/A,MYID/A,SRCP/A,DSTP/A"
  17. lf='0a'x
  18. if strip(arguments) = '?' then do
  19.     Call WriteCh(STDOUT, ArgsTemplate || ': ')
  20. pull arguments
  21. end; else nop
  22. if ~ReadArgs(arguments,ArgsTemplate) then do
  23.     say Fault(RC,ProgramName)
  24.      exit 10
  25. end; else nop
  26. drop arguments
  27. catalog=opencatalog('Install.dopus5.catalog','english',0)
  28.  
  29. address value PORT
  30.  
  31. inlocpr='DOpus5:System/Install_Locale.prefs'
  32. if ~open(lp,inlocpr,'READ') then do
  33.     dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(15,'Unable to open') inlocpr || '"' GetCatStr(0,'Abort')
  34.     Call CleanUP
  35.     exit
  36. end
  37. junk=readln(lp)
  38. month=1
  39. do while month < 13
  40.     cnt=0
  41.     do while cnt<9
  42.         d.month.cnt=readln(lp)
  43.         cnt=cnt+1
  44.     end
  45.     month=month+1
  46. end
  47. d.tr=readln(lp)
  48. Call Close(lp)
  49.  
  50.  
  51. MYPORTH=openport(MYPORT)
  52.  
  53. do until CMD='0'
  54.     call waitpkt(MYPORT)
  55.     Packet=getpkt(MYPORT)
  56.     if Packet ~= null() then do
  57.         ln = getarg(Packet,0)
  58.         ID=substr(ln,1,1)
  59.         CMD=substr(ln,2,1)
  60.         ARG=substr(ln,3)
  61.         call CheckArg
  62.         IF ID=0 & CMD>0 THEN DO
  63.             parse var arg path '0a'x name '0a'x fdate.1 '0a'x fdate.2 '0a'x vdate.1 '0a'x vdate.2 '0a'x size.1 '0a'x size.2 '0a'x base.1 '0a'x base.2 '0a'x ver.1 '0a'x ver.2 '0a'x rev.1 '0a'x rev.2 '0a'x info.1 '0a'x info.2 '0a'x com.1 '0a'x com.2 '0a'x ps
  64.             req=''
  65.             if path~='' then req=path || lf
  66.             req=req || name || lf || lf
  67.             
  68.             cnt=1
  69.             do while cnt<3
  70.                 if cnt=1 then req=req || GetCatStr(59,'Source') || ':' srcp || lf
  71.                 if cnt=2 then req=req || lf || GetCatStr(60,'Destination') || ':' dstp || lf
  72.     
  73.                 req=req || size.cnt 'bytes' || ','
  74.                 t=fdate.cnt
  75.                 call GetTime
  76.                 req=req hours || ':' || mins || ':' || secs || ',' dt || lf
  77.                 
  78.                 if base.cnt~='' then req=req base.cnt
  79.                 
  80.                 if ver.cnt~=0 | rev.cnt~=0 then req=req ver.cnt || '.' || rev.cnt
  81.                 
  82.                 if vdate.cnt~=0 then do
  83.                     days=vdate.cnt
  84.                     Call GetDate
  85.                     req = req '(' || dt || ')'
  86.                 end
  87.  
  88.                 if base.cnt~='' | ver.cnt~=0 | rev.cnt~=0 | vdate.cnt~=0 then req=req || lf
  89.  
  90.                 if info.cnt ~= '' then req=req || info.cnt || lf
  91.                 if com.cnt ~= '' then req=req || com.cnt || lf
  92.                 cnt=cnt+1
  93.             end
  94.             req=left(req,length(req)-1)
  95.             addlf=lf
  96.             
  97.             IF CMD~=5 & CMD~=7 THEN DO
  98.                 IF CMD=1 | CMD=6 THEN DO
  99.                     req=req || addlf || lf || GetCatStr(63,'Warning: Destination file is delete protected!')
  100.                     addlf=''
  101.                 end
  102.                 else do
  103.                     prot=statef(makepath(makepath(dstp,path),name))
  104.                     parse var prot . ' ' . ' ' . ' ' prot ' ' .
  105.                     if RIGHT(prot,1)='-' then do
  106.                         req=req || addlf || lf || GetCatStr(63,'Warning: Destination file is delete protected!')
  107.                         addlf=''
  108.                         if CMD=2 then CMD=8
  109.                         if CMD=3 then CMD=1
  110.                     end
  111.                 end
  112.             end
  113.  
  114.             IF CMD~=4 & CMD~=6 THEN DO
  115.                 IF CMD=2 | CMD=7 THEN DO
  116.                     req=req || addlf || lf || GetCatStr(62,'Warning: Source file is delete protected!')
  117.                     addlf=''
  118.                 end
  119.                 else do
  120.                     prot=statef(makepath(makepath(srcp,path),name))
  121.                     parse var prot . ' ' . ' ' . ' ' prot ' ' .
  122.                     if RIGHT(prot,1)='-' then do
  123.                         req=req || addlf || lf || GetCatStr(63,'Warning: Source file is delete protected!')
  124.                         addlf=''
  125.                         if CMD=1 then CMD=8
  126.                         if CMD=3 then CMD=2
  127.                     end
  128.                 end
  129.             end
  130.  
  131.             if CMD>0 & CMD<9 then do
  132.                 if CMD=1 | CMD=2 | CMD=3 | CMD=8 then do
  133.                     dopus request '"' || req || '"' GetCatStr(53,'repl Dest') || '|' || GetCatStr(54,'repl Source') || '|' || GetCatStr(55,'skip')
  134.                     answ=rc
  135.                 end
  136.                 if CMD=4 | CMD=6 then do
  137.                     dopus request '"' || req || '"' GetCatStr(53,'repl Dest') || '|' || GetCatStr(55,'skip')
  138.                     answ=rc
  139.                 end
  140.                 if CMD=5 | CMD=7 then do
  141.                     dopus request '"' || req || '"' GetCatStr(54,'repl Source') || '|' || GetCatStr(55,'skip')
  142.                     answ=rc
  143.                     if answ=1 then answ=2
  144.                 end
  145.                 if answ=0 then answ=3
  146.                 if answ=1 then do
  147.                     if CMD=6 | CMD=1 | CMD=8 then do
  148.                         command wait protect '"' || makepath(makepath(dstp,path),name) || '"' SET D
  149.                     end
  150.                     dopus send EXPORT MYID || answ || path || lf || name
  151.                 end
  152.                 if answ=2 then do
  153.                     if CMD=7 | CMD=2 | CMD=8 then do
  154.                         command wait protect '"' || makepath(makepath(srcp,path),name) || '"' SET D                    
  155.                     end
  156.                     dopus send EXPORT MYID || answ || path || lf || name
  157.                 end
  158.                 dopus send MNPORT MYID || answ || ps
  159.             end
  160.         end
  161.     end
  162. end    
  163. Call CleanUP
  164. exit
  165.  
  166.  
  167. GetTime:
  168. days=t % 86400
  169. t=t // 86400
  170. hours=t % 3600
  171. t=t // 3600
  172. mins=t % 60
  173. t=t // 60
  174. secs=t
  175. hours=copies('0',2-length(hours)) || hours
  176. mins=copies('0',2-length(mins)) || mins
  177. secs=copies('0',2-length(secs)) || secs
  178. Call GetDate
  179. return
  180.  
  181.  
  182. GetDate:
  183. dt=date('s',days,'i')
  184. year=substr(dt,1,4)
  185. month=substr(dt,5,2)
  186. if left(month,1)='0' then month=substr(month,2)
  187. day=substr(dt,7,2)
  188. dt=copies(' ',d.month.0)
  189. dt=overlay(d.tr,dt,d.month.1)
  190. dt=overlay(d.tr,dt,d.month.2)
  191. dt=overlay(d.month.8,dt,d.month.6)
  192. dt=overlay(day,dt,d.month.3)
  193. dt=overlay(substr(year,3),dt,d.month.4)
  194. if d.month.5~=0 then do
  195.     dt=overlay(left(year,2),dt,d.month.5)
  196. end
  197. return
  198.  
  199.  
  200. CheckArg:
  201. IF DATATYPE(ID)~='NUM' | DATATYPE(CMD)~='NUM' THEN Call CheckArgFail
  202. IF ID~=0 THEN Call CheckArgFail
  203. IF CMD>5 THEN Call CheckArgFail
  204. RETURN
  205.  
  206.  
  207. CheckArgFail:
  208. address value PORT
  209. dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(52,'Invalid packet received') || lf || 'ID=' || ID || lf || 'CMD=' || CMD || lf || 'ARG=' || ARG || '"' GetCatStr(0,'Abort')
  210. Call CleanUP
  211. exit
  212.  
  213.  
  214.  
  215. ERROR:
  216. HALT:
  217. IOERR:
  218. SYNTAX:
  219. IF RC ~= 0 THEN DO
  220.  line=sigl
  221.  text=errortext(rc)
  222.  dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || text || lf || GetCatStr(19,'Line') line || '"' GetCatStr(0,'Abort')
  223. END
  224. else do
  225.  dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || '"' GetCatStr(0,'Abort')
  226. end
  227. BREAK_C:
  228. BREAK_D:
  229. BREAK_E:
  230. BREAK_F:
  231. Call CleanUP
  232. exit
  233.  
  234.  
  235. CleanUp:
  236. dopus send MNPORT MYID || 0
  237. if POS(MYPORT,SHOW('p'))~=0 then do
  238.     Call FORBID()
  239.     Call ClosePort(MYPORTH)
  240.     Call PERMIT()
  241. end
  242. Call CloseCatalog(catalog)
  243. return
  244.  
  245.  
  246. getcatstr: /* Thank you for this procedure, Edmund */
  247. parse arg msgno,msgstring
  248. if catalog~=0 then
  249.    msgstring=getcatalogstr(catalog,msgno,msgstring)
  250. do i=3 to arg()
  251.    parse var msgstring fore '%s' aft
  252.    msgstring=fore||arg(i)||aft
  253.    end
  254. return msgstring
  255.